<script type="text/javascript">
$ (function (){
	$('#stn').autocomplete(${(type)!'[]'}, {
		max: 12,    //列表里的条目数
		minChars: 0,    //自动完成激活之前填入的最小字符
		width: 200,     //提示的宽度，溢出隐藏
		scrollHeight: 300,   //提示的高度，溢出显示滚动条
		matchContains: true,    //包含匹配，就是data参数里的数据，是否只要包含文本框里的数据就显示
		autoFill: false,    //自动填充
		formatItem: function(row, i, max) {
		 return i + '/' + max + ':"' + row.stn + '"';
		},
		formatMatch: function(row, i, max) {
		 return row.stn + row.stc;
		},
		formatResult: function(row) {
		  return row.stn;
		}
	}).result(function(event, row, formatted) {
		$('#stc').val(row.stc);
	});
	$('#editForm').find("input:radio").not('input.ibtn').uniform();
});

</script>
<#import "/freemarker/modeltype.ftl" as mt>
<#import "/freemarker/modeltype_entity.ftl" as mte>
<div>
	<h3 class="title"><i class="fontello-icon-th-list-1"></i> 编辑来往单位信息</h3>
</div>
<div class="widget" >
	<div class="widget-content">
		<form id="editForm">
			<table style="width:70%;"  class="table table-bordered animate2 fadeInUp">
				<tr>
					<td>名称</td>
					<td>
						<input type="text" id="name" name="name" value="${(invBusiness.name)!''}" />
						<input type="hidden" id="code" name="code" value="${(invBusiness.code)!''}" />
					</td>
					<td>编号</td>
					<td><input type="text" id="sid" name="sid" value="${(invBusiness.sid)!''}" /></td>
				</tr>
				<tr>
					<td>邮箱号</td>
					<td><input type="text" id="email" name="email" value="${(invBusiness.email)!''}" onblur="javascript:validateEmail_invBusiness($(this));"/></td>
					<td>传真</td>
					<td><input type="text" id="fax" name="fax" value="${(invBusiness.fax)!''}" /></td>
				</tr>
				<tr>
					<td>联系电话</td>
					<td><input type="text" id="phone" name="phone" value="${(invBusiness.phone)!''}" /></td>
					<td>地址</td>
					<td><input type="text" id="address" name="address" value="${(invBusiness.address)!''}" /></td>
				</tr>
				</tr>
				<tr>
					<td>所属类别</td>
					<td>
						<input id="stn" type="text" name="stn" value="${(invBusiness.stn)!''}">
						<input id="stc" type="hidden" name="stc" value="${(invBusiness.stc)!''}">
					</td>
					<td rowspan="2">备注</td>
					<td rowspan="2"><textarea name="remark" value="${(inBusiness.remark)!''}"/></td>
				</tr>
				<tr>
					<td>单位性质(可多选)</td>
					<td>
						<input class="box" type="checkbox" name="type" value="1"  onclick="javascript: check2_invBusiness($(this));" <#if invBusiness?? && invBusiness.type = 1>checked=""</#if>/>&nbsp;供应商&nbsp;
						<input class="box" type="checkbox" name="type" value="2"  onclick="javascript: check2_invBusiness($(this));"<#if invBusiness?? && invBusiness.type = 2>checked=""</#if>/>&nbsp;客户&nbsp;
						<input class="box" type="checkbox" name="type" value="3"  onclick="javascript: check2_invBusiness($(this));"<#if invBusiness?? && invBusiness.type = 3>checked=""</#if>/>&nbsp;两者皆是&nbsp;
						<input class="box" type="checkbox" name="type" value="4"  onclick="javascript: check2_invBusiness($(this));"<#if invBusiness?? && invBusiness.type = 4>checked=""</#if>/>&nbsp;其他
					</td>
				</tr>
			</table>
			<table  style="width:70%;" class="table table-bordered animate2 fadeInUp">
				<thead>
					<tr>
						<th style="text-align:center;">联系人名称<a href="javascript:;" onclick="javascript:add_invBusiness();" style="margin-left: 10px">[添加空白行]</a></th>
						<th style="text-align:center;">电话</th>
						<th style="text-align:center;">QQ</th>
						<th style="text-align:center;">首要联系人</th>
						<th style="width:32px;">操作</th>
					</tr>
				</thead>
				<tbody id="ListBody">
				<#assign i = 0 />
					<#if ((invBusiness.itemList)?? && invBusiness.itemList?size > 0)>
					<#list invBusiness.itemList as item>
					<tr class="rep">
						<td><input class="name" type="text" name="itemList[${i}].name" value="${(item.name)!''}"/>
							<input type="hidden" name="itemList[${i}].code" value="${(item.code)!''}" />
						</td>
						<td><input class="phone" type="text" name="itemList[${i}].phone" value="${(item.phone)!''}" style="width:150px;"/></td>
						<td><input class="qq" type="text" name="itemList[${i}].qq" value="${(item.qq)!''}" style="width:100px;" onkeyup="javascript:checkNum_invBusiness($(this));"/></td>
						<td style="text-align:center;"><input class="dc" type="checkbox" name="itemList[${i}].dc" <#if item.dc == true>checked <#else></#if>  onclick="javascript: check1_invBusiness($(this));"/></td>
						<td style="text-align:center;"><a class="btn btn-danger" href="javascript:;" onclick="javascript:delete_invBusiness($(this));"><i class="icon-remove"></i></a></td>
					</tr>
					<#assign i = i + 1/></#list><#else>
					<tr class="rep">
						<td><input class="name" type="text" name="itemList[${i}].name"/></td>
						<td><input class="phone" type="text" name="itemList[${i}].phone" style="width:150px;"/></td>
						<td><input class="qq" type="text" name="itemList[${i}].qq" style="width:100px;" onkeyup="javascript:checkNum_invBusiness($(this));"/></td>
						<td style="text-align:center;"><input class="dc" type="checkbox" name="itemList[${i}].dc" onclick="javascript: check1_invBusiness($(this));"/></td>
						<td style="text-align:center;"><a class="btn btn-danger" href="javascript:;" onclick="javascript:delete_invBusiness($(this));"><i class="icon-remove"></i></a></td>
					</tr>
					<#assign i = i + 1/></#if>
				</tbody>
				<tr>
					<td colspan="5" style="text-align: center;">
						<a href="javascript:;" class="btn btn-info" onclick="javascript: save_invBusiness(); return false;"><i class="icon-save"></i>&nbsp;保&nbsp;&nbsp;存</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<a href="javascript:;" class="btn btn-primary" onclick="javascript: sys_load_handle('invBusiness');"><i class="fontello-icon-block"></i>&nbsp;取&nbsp;&nbsp;消</a>
					</td>
				</tr>
			</table>
		</form>
	</div>
</div>


<input type="hidden" id="index" value="${i}" />
<table id="tempTable" style="display:none;">
	<tr class="rep">
		<td><input class="name" type="text" /></td>
		<td><input class="phone" type="text" style="width:150px;"/></td>
		<td><input class="qq" type="text" style="width:100px;" onkeyup="javascript:checkNum_invBusiness($(this));"/></td>
		<td style="text-align:center;"><input class="dc" type="checkbox" onclick="javascript: check1_invBusiness($(this));"/></td></td>
		<td style="text-align:center;"><a class="btn btn-danger" href="javascript:;" onclick="javascript:delete_invBusiness($(this));"><i class="icon-remove"></i></a></td>
	</tr>
</table>